﻿<UserControl x:Class="DotBeer.UI.WPFClient.HeroesCollectionControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:logic="clr-namespace:DotBeer.Business.Components;assembly=DotBeer.Business.Components"
	xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:business="clr-namespace:DotBeer.Business.Entities;assembly=DotBeer.Business.Entities"
    xmlns:local="clr-namespace:DotBeer.UI.WPFClient"
    Height="Auto" 
    Width="Auto" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:PresentationLayer="clr-namespace:DotBeer.UI.WPFClient"
    mc:Ignorable="d">
    <UserControl.Resources>
        <ObjectDataProvider x:Key="sideData"
							MethodName="GetValues"
							ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="business:Side"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <ObjectDataProvider x:Key="tavernsData" ObjectType="{x:Type logic:TavernsCollectionComponent}" d:IsDataSource="True" MethodName="Load"/>
        <local:TavernHeroConverter x:Key="tavernConverter"/>
        <local:LoadImageWithoutLockFileConverter x:Key="imageConverter"/>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="340"/>
            <ColumnDefinition Width="Auto" MinWidth="194"/>
        </Grid.ColumnDefinitions>
        <ListView IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" KeyUp="ListView_KeyUp" x:Name="ListViewHeroes" Margin="5,5,5,5" Style="{DynamicResource ListViewStyle}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Image" Width="50">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Image Source="{Binding Path=ImagePath, Mode=OneWay, Converter={StaticResource imageConverter}}" Width="30" Height="30"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Name" Width="200">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Path=Name}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
        <Grid HorizontalAlignment="Stretch" Width="Auto" Grid.Column="1" Grid.RowSpan="1" VerticalAlignment="Stretch" Height="Auto">
        	<Grid.RowDefinitions>
        		<RowDefinition Height="40"/>
        		<RowDefinition Height="40"/>
        		<RowDefinition Height="40"/>
        		<RowDefinition Height="40"/>
                <RowDefinition Height="40"/>
                <RowDefinition Height="40"/>
        	</Grid.RowDefinitions>
        	<Grid.ColumnDefinitions>
        		<ColumnDefinition Width="46.65"/>
        		<ColumnDefinition Width="*" MaxWidth="200"/>
        	</Grid.ColumnDefinitions>
        	<TextBlock Text="Name:" TextWrapping="Wrap" d:LayoutOverrides="Height" VerticalAlignment="{DynamicResource TextBlockVerticalAlignemnt}" HorizontalAlignment="{DynamicResource TextBlockHorizontalAlignment}" Margin="{DynamicResource TextBlockMargin}"/>
        	<TextBlock Margin="5,0,0,0" Text="Tavern:" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Row="2" HorizontalAlignment="Left"/>
        	<TextBlock Margin="5,0,0,0" Text="Side:" TextWrapping="Wrap" Grid.Row="3" HorizontalAlignment="Left" VerticalAlignment="Center"/>
        	<TextBlock Text="Position:" TextWrapping="Wrap" VerticalAlignment="Center" Margin="5,0,0,0" Grid.Row="4" HorizontalAlignment="Left"/>
        	<ComboBox IsSynchronizedWithCurrentItem="True" SelectedValue="{Binding Path=/TavernHero, Converter={StaticResource tavernConverter}}" x:Name="ComboBoxTaverns" SelectedValuePath="Name" Style="{DynamicResource ComboBoxStyle}" Margin="{DynamicResource EditControlMargin}" Grid.Column="1" Grid.Row="2" d:LayoutOverrides="Height" VerticalAlignment="{DynamicResource EditControlVerticalAlignment}" HorizontalAlignment="{DynamicResource EditControlHorizontalAlignment}"/>
            <TextBox TextWrapping="Wrap" Style="{DynamicResource TextBoxStyle}" Grid.Column="1" d:LayoutOverrides="Height" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="5,0,5,0">
                <Binding Path="/Name" UpdateSourceTrigger="PropertyChanged" NotifyOnValidationError="True">
                    <Binding.ValidationRules>
                        <PresentationLayer:NameValidation></PresentationLayer:NameValidation>
                    </Binding.ValidationRules>
                </Binding>
            </TextBox>
            <TextBox Text="{Binding Path=/Position}" TextWrapping="Wrap" Style="{DynamicResource TextBoxStyle}" Margin="5,0,5,0" Grid.Column="1" Grid.Row="4
                     " d:LayoutOverrides="Height" VerticalAlignment="Center" HorizontalAlignment="Stretch" PreviewTextInput="TextBox_PreviewTextInput" />
        	<ComboBox Style="{DynamicResource ComboBoxStyle}" IsSynchronizedWithCurrentItem="True" SelectedValue="{Binding Path=/Side}" ItemsSource="{Binding Mode=OneWay, Source={StaticResource sideData}}" Margin="5,0,5,0" d:LayoutOverrides="Width, Height" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Center" Name="ComboBoxSide"/>
            <Button x:Name="ButtonAdd" Content="Add new hero" Style="{StaticResource ButtonLightStyle}" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center" Height="20" Margin="5,0,5,0" Click="ButtonAdd_Click"/>
            <TextBlock Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="5,0,0,0" Text="Image:" TextWrapping="Wrap" Width="37.453" Grid.Row="1" VerticalAlignment="Center" />
            <Image HorizontalAlignment="Left" Width="40" Grid.Column="1" Grid.RowSpan="1" Height="40" Grid.Row="1" Margin="5,0,0,0" Source="{Binding Path=ImagePath, Mode=OneWay, Converter={StaticResource imageConverter}}"/>
            <Button HorizontalAlignment="Right" VerticalAlignment="Center" Content="..." Style="{DynamicResource ButtonLightStyle}" Grid.Row="1" Grid.Column="1" Height="20" Width="30" Margin="0,0,5,0" x:Name="ButtonImagePath" Click="ButtonImagePath_Click"/>
        </Grid>
    </Grid>
</UserControl>
